﻿#pragma once
#include <QWidget>
#include<QString>
#include <QFile>
#include <QChar>
#include <QDebug>
#include <QColor>
#include <QByteArray>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QMessageBox>
#include <AsThread>
#include <QFileDialog>

#include "BaseDefine.h"
#include "ui_ApMainWindow.h"

QT_BEGIN_NAMESPACE
namespace Ui { class ApMainWindowClass; };
QT_END_NAMESPACE

class ApMainWindow : public QWidget {
	Q_OBJECT

public:
	ApMainWindow(QWidget *parent = nullptr);
	~ApMainWindow();

	CN::TableSize  getCurrentTableSize();
	int computeOffset(QString hzStr);
protected:
	

public slots:
	void on_pushButton_show_clicked();
	void on_pushButton_clear_clicked();
	void on_pushButton_edit_clicked();
	void on_pushButton_quit_clicked();
	void on_pushButton_update_clicked();
	void on_pushButton_add_clicked();
	void on_toolButton_clicked();

	void updatePixLength(int length);
	void shiftCellState(int x, int y);
	void shiftComboIndex(int index);
private:
	void init();
	void initMat();

	//得到点阵
	void updateMat16(QString str);
	void updateMat24(QString str);
	void updateMat32(QString str);
	void updateMat48(QString str);

	void writeMat16();
	void writeMat24();
	void writeMat32();
	void writeMat48();

	
	void updateCellStateAndMat(int x,int y,cv::Mat &mat);
	
private:
	Ui::ApMainWindowClass *ui;
	cv::Mat m_mat16;
	cv::Mat m_mat24;
	cv::Mat m_mat32;
	cv::Mat m_mat48;
	QString m_filePath16;
	QString m_filePath24;
	QString m_filePath32;
	QString m_filePath48;
	int m_offset = 0;
	AsThread *m_pThread;

};
